	var initImageCount = 0;
	function fileDialogStart() {
		var stats = swfu.getStats();
		stats.successful_uploads += initImageCount;
		stats.successful_uploads -= removeCount;
		swfu.setStats(stats);
		initImageCount = 0;
		removeCount = 0;
	}
	
	var swfu;
	function initUpload() {
		swfu = new SWFUpload({
			upload_url: "/super/upload",
			file_size_limit : "1 MB",
			file_types : "*.jpg;*.gif;*.png;*.bmp;*.jpeg",
			file_types_description : "Image Files",
			file_upload_limit : "3",
			file_post_name: "data",
	
			file_dialog_start_handler: fileDialogStart,
			file_queue_error_handler : fileQueueError,
			file_dialog_complete_handler : fileDialogComplete,
			upload_progress_handler : uploadProgress,
			upload_error_handler : uploadError,
			upload_success_handler : uploadSuccess,
			upload_complete_handler : uploadComplete,
	
			// Button Settings
			button_placeholder_id : "spanButtonPlaceholder",
			button_image_url: "../js/swfupload/uploadBtn.png",
			button_width: 60,
			button_height: 48,
			//button_text : '浏览',
			//button_text_style : '',
			//button_text_top_padding: 0,
			//button_text_left_padding: 0,
			//button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
			button_cursor: SWFUpload.CURSOR.HAND,
			
			// Flash Settings
			flash_url : "../js/swfupload/swfupload.swf",
	
			custom_settings : {
				upload_target : "divFileProgressContainer"
			}
		});
	}
	
	// 重写方法
	function addImage(filePath) {
		var html = '<dl>'
				+ '	<dt>'
				+ '		<a href="javascript:void(0);"><em><img id="previewImg" ondblclick="" width="120" height="100" onclick="" src="' + filePath + '"></em></a>'
				+ '	</dt>'
				+ '	<dd>'
				+ '	<a href="javascript:void(0);"><img onclick="javascript:previewBig(\'' + filePath + '\');" title="预览" alt="view" src="../images/icon_zoomout.gif"></a>'	
				+ '	<a href="javascript:void(0);"><img onclick="javascript:removeImage($(this), \'' + filePath + '\');" title="删除" alt="delete" src="../images/icon_delete15.gif"></a>'
				+ '	</dd>'
				+ '</dl>';
		var li = $("<li></li>");
		li.html(html);
		$("#uploadButton").append(li);
	}
	
	function uploadSuccessCallback(filePath) {
		var img1 = $("#image1");
		var img2 = $("#image2");
		var img3 = $("#image3");
		if (img1 != null && (img1.val() == null || img1.val() == ""))
			img1.val(filePath);
		else if (img2 != null && (img2.val() == null || img2.val() == ""))
			img2.val(filePath);
		else if (img3 != null && (img3.val() == null || img3.val() == ""))
			img3.val(filePath);
	}
	
	var removeCount = 0;
	function removeImage(img, src) {
		$(img).parents("li").eq(0).remove();
		var img1 = $("#image1");
		var img2 = $("#image2");
		var img3 = $("#image3");
		if (img1.val() == src)
			img1.val("");
		else if (img2.val() == src)
			img2.val("");
		else if (img3.val() == src)
			img3.val("");
		removeCount++;
		
		/*	
		// 此处运用改变file_upload_limit的解决方案
		swfu.setFileUploadLimit(parseInt(swfu.settings.file_upload_limit) + 1);
		*/
	}
	
	function previewBig(src) {
		window.open(src);
	}